﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace tsgl
{
    class queryLoanClass
    {
        public static DataTable getLoaninfoAll()
        {
            return bookDbClass.ExecuteDataTable("select 借阅者编号,姓名,图书条码,书目编号,图书名称,价格,借出日期,应还日期,续借次数,图书借阅员 from loanView");
        }

        //public static DataTable findByCondition(string strCondition)
        //{
        //    return bookDbClass.ExecuteDataTable("select 借阅者编号,姓名,图书条码,书目编号,图书名称,价格,借出日期,应还日期,续借次数,图书借阅员 from loanView where " + strCondition + "");
        //}

        public static DataTable getOverdueInfo()
        {
            return bookDbClass.ExecuteDataTable("select 借阅者编号,姓名,图书条码,图书名称,价格,借出日期,应还日期,续借次数,图书借阅员,书目编号 from loanView where 应还日期 < @a",new SqlParameter("a",DateTime.Now.ToShortDateString()));
        }

        public static DataTable getBorrowerInfoAll()
        {
            return bookDbClass.ExecuteDataTable("select 借阅者编号,姓名,性别,出生日期,借阅者类型,借书证状态,办证日期,有效期截止日期,证件号码,联系电话,部门名称,押金剩余 from borrowerView");
        }

        public static DataTable getBorrowerInfoById(string borrowerId)
        {
            return bookDbClass.ExecuteDataTable("select 借阅者编号,姓名,性别,出生日期,借阅者类型,借书证状态,办证日期,有效期截止日期,证件号码,联系电话,部门名称,押金剩余 from borrowerView where 借阅者编号 like '" + borrowerId + "%'");
        }

        public static DataTable getBorrowerInfoByName(string borrowerName)
        {
            return bookDbClass.ExecuteDataTable("select 借阅者编号,姓名,性别,出生日期,借阅者类型,借书证状态,办证日期,有效期截止日期,证件号码,联系电话,部门名称,押金剩余 from borrowerView where 姓名 like '%"+borrowerName+ "%'");
        }

        public static DataTable getBibliothecaInfoById(string bibliothecaId)
        {
            return bookDbClass.ExecuteDataTable("select 书目编号,图书名称,作者,出版社名称,ISBN,出版日期,图书页数,价格,图书类型名称,总藏书数量,现存数量,馆藏地点,简介 from bibliothecaView where 书目编号 like '"+ bibliothecaId +"%'");
        }

        public static DataTable getBibliothecaInfoByName(string bibliothecaName)
        {
            return bookDbClass.ExecuteDataTable("select 书目编号,图书名称,作者,出版社名称,ISBN,出版日期,图书页数,价格,图书类型名称,总藏书数量,现存数量,馆藏地点,简介 from bibliothecaView where 图书名称 like '%" + bibliothecaName + "%'");
        }
    }
}
